package org.travel.travel2gether.service;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.travel.travel2gether.builder.TrackBuilder;
import org.travel.travel2gether.dao.TrackDao;
import org.travel.travel2gether.domain.Track;
import org.travel.travel2gether.dto.TrackForm;

@Service
public class TrackService {

	
	@Autowired TrackDao trackDao;
	@Autowired UserService userService;
	
	
	public Track addTrack(TrackForm trackForm) {
		Track track = TrackBuilder.createTrack(trackForm);

		track.setAccount(userService.getCurrentAccount());
		
		Track save = trackDao.save(track);
		
		return save;
	}
	
	public Track findOne(Long id) {
		return trackDao.findOne(id);
	}
	
	
}
